<?php
/**
 * User: hjd-yao
 * Date: 2018/11/4
 * Time: 16:14
 */

Route::get('/',function (){
    return redirect()->route('b_Index_index');
});
Route::namespace('Auth')->prefix('auth')->group(function (){

    Route::get('index')->uses('LoginController@showLoginForm')->name('b_Login_showLoginForm');

    Route::post('login')->uses('LoginController@login')->name('b_Login_login');

    Route::get('logout')->uses('LoginController@logout')->name('b_Login_logout')->middleware('CheckIsLogin');
});

Route::namespace('Uploader')->prefix('upload')->middleware('CheckIsLogin')->group(function (){

    Route::get('upload-frame/{img_num}/{group}/{parent_box}')->uses('UploaderController@uploadFrame')->name('b_Uploader_uploadFrame')
        ->where(['img_num'=>'[1|4|6]','group'=>'^[A-Za-z][a-zA-Z0-9_]*','parent_box'=>'^[A-Za-z][a-zA-Z0-9_]*']);

    Route::match(['get','post'],'image')->uses('UploaderController@server')->name('b_Uploader_server');

    Route::match(['get','post'],'editor')->uses('UploaderController@uEdit')->name('b_Uploader_uEdit');
});

Route::namespace('Backend')->middleware(['CheckIsLogin','CheckAuth'])->group(function (){

    Route::prefix('home')->group(function (){
        Route::get('index')->uses('IndexController@index')->name('b_Index_index');

        Route::get('statistics')->uses('IndexController@statisticalInfo')->name('b_Index_statisticalInfo');

        Route::get('chart-user')->uses('IndexController@chartUserData')->name('b_Index_chartUserData');

        Route::get('chart-order')->uses('IndexController@chartOrderData')->name('b_Index_chartOrderData');
    });

    Route::prefix('role')->group(function (){

        Route::get('list')->uses('RoleController@showRoles')->name('b_Role_showRoles');

        Route::match(['post','get'],'add')->uses('RoleController@showAddRoleForm')->name('b_Role_showAddRoleForm');

        Route::match(['post','get'],'edit/{role_id}')->uses('RoleController@editRole')->name('b_Role_editRole')
            ->where('role_id','[0-9]+');

        Route::match(['post','get'],'authorization/{role_id}')->uses('RoleController@authRole')->name('b_Role_authRole')
            ->where('role_id','[0-9]+');

        Route::get('switch/{role_id}')->uses('RoleController@switchRole')->name('b_Role_switchRole')
            ->where('role_id','[0-9]+');

        Route::get('remove/{role_id}')->uses('RoleController@deleteRole')->name('b_Role_deleteRole')
            ->where('role_id','[0-9]+');
    });

    Route::prefix('menu')->group(function (){
        Route::get('list')->uses('MenuController@showAllMenus')->name('b_Menu_showAllMenus');

        Route::match(['post','get'],'add/{parent_id?}')->uses('MenuController@addMenus')->name('b_Menu_addMenus')
            ->where('parent_id','[0-9]+');

        Route::match(['get','post'],'edit/{menu_id}')->uses('MenuController@editMenu')->name('b_Menu_editMenu')
            ->where('menu_id','[0-9]+');

        Route::post('remove/{menu_id}')->uses('MenuController@deleteMenus')->name('b_Menu_deleteMenus')
            ->where('menu_id','[0-9]+');

        Route::post('switch/{menu_id}')->uses('MenuController@switchMenu')->name('b_Menu_switchMenu')
            ->where('menu_id','[0-9]+');
    });

    Route::prefix('admin')->group(function (){
        Route::get('index')->uses('AdminController@index')->name('b_Admin_index');

        Route::get('info/{admin_name}')->uses('AdminController@info')->name('b_Admin_info')
            ->where('admin_name','^[A-Za-z][a-zA-Z0-9_]*');

        Route::get('add')->uses('AdminController@showAddAdminForm')->name('b_Admin_showAddAdminForm');
        Route::post('save')->uses('AdminController@save')->name('b_Admin_save');

        Route::get('{admin_name}/edit')->uses('AdminController@showEditAdminForm')->name('b_Admin_showEditAdminForm')
                ->where('admin_name','^[A-Za-z][a-zA-Z0-9_]*');

        Route::post('{admin_name}/update')->uses('AdminController@update')->name('b_Admin_update')
            ->where('admin_name','^[A-Za-z][a-zA-Z0-9_]*');

        Route::match(['post','get'],'{admin_name}/delete')->uses('AdminController@delete')->name('b_Admin_delete')
            ->where('admin_name','^[A-Za-z][a-zA-Z0-9_]*');

        Route::match(['post','get'],'{admin_name}/switch')->uses('AdminController@switchAdminStatus')->name('b_Admin_switchAdminStatus')
            ->where('admin_name','^[A-Za-z][a-zA-Z0-9_]*');

        Route::get('change-pwd')->uses('AdminController@changePwdForm')->name('b_Admin_changePwdForm');
        Route::post('update-pwd/{action}')->uses('AdminController@updatePwd')->name('b_Admin_updatePwd')
                ->where('action','login|safe');

        Route::get('reset-pwd/{admin_name}')->uses('AdminController@resetPwdForm')->name('b_Admin_resetPwdForm')
                ->where('admin_name','^[A-Za-z][a-zA-Z0-9_]*');

        Route::post('reset/{admin_name}/{action}')->uses('AdminController@reset')->name('b_Admin_reset')
                ->where(['admin_name'=>'^[A-Za-z][a-zA-Z0-9_]*','action'=>'login|safe']);

        Route::match(['get','post'],'grant-roles/{admin_name}')->uses('AdminController@grantRoles')->name('b_Admin_grantRoles')
            ->where(['admin_name'=>'^[A-Za-z][a-zA-Z0-9_]*']);

    });

    Route::prefix('config')->group(function (){

        Route::get('{group?}')->uses('ConfigController@showConfig')->name('b_Config_showConfig')
            ->where('group','[0-9]+');

        Route::post('update/{group}')->uses('ConfigController@updateValue')->name('b_Config_updateValue')
            ->where('group','[0-9]+');

        Route::get('set')->uses('ConfigController@websiteSet')->name('b_Config_websiteSet');

        Route::match(['get', 'post'], 'bonus-rule')->uses('ConfigController@bonusRule')->name('b_Config_bonusRule');


        Route::match(['get', 'post'], 'sys-rule')->uses('ConfigController@sysRule')->name('b_Config_sysRule');


        Route::match(['get', 'post'], 'current-rule')->uses('ConfigController@currentRule')->name('b_Config_currentRule');


        Route::match(['get', 'post'], 'bonus-rule-switch/{rule_id}')->uses('ConfigController@switchRule')
            ->name('b_Config_switchRule')->where('rule_id', '[0-9]+');

        Route::match(['post','get'],'rule')->uses('ConfigController@rules')->name('b_Config_rules');

        Route::match(['post','get'],'gongzi')->uses('ConfigController@gongzi')->name('b_Config_gongzi');
        Route::match(['post','get'],'futou_cheak')->uses('ConfigController@futouCheak')->name('b_Config_futou_cheak');


    });

    Route::prefix('currency')->group(function (){

        Route::match(['post','get'],'edit/{currency_id}')->uses('CurrencyController@update')->name('b_Currency_update')
            ->where('currency_id','[0-9]+');
    });

    Route::prefix('change')->group(function (){

        Route::match(['post','get'],'edit/{type_id}')->uses('ChangeTypeController@update')->name('b_ChangeType_update')
            ->where('type_id','[0-9]+');
    });

    Route::prefix('area')->group(function (){
        Route::get('list/{parent_id?}')->uses('AreaController@showArea')->name('b_Area_showArea')
            ->where('parent_id','[0-9]+');

        Route::match(['get','post'],'add/{parent_id?}')->uses('AreaController@addArea')->name('b_Area_addArea')
            ->where('parent_id','[0-9]+');

        Route::match(['get','post'],'edit/{id}')->uses('AreaController@editArea')->name('b_Area_editArea')
            ->where('id','[0-9]+');

        Route::match(['get','post'],'remove/{id}')->uses('AreaController@deleteArea')->name('b_Area_deleteArea')
            ->where('id','[0-9]+');

        Route::get('file')->uses('AreaController@exportAreaFile')->name('b_Area_exportAreaFile');

        Route::get('/')->uses('AreaController@getArea')->name('b_Area_getArea');
    });

    Route::prefix('website')->group(function (){
        Route::get('clear')->uses('SystemController@clearCache')->name('b_System_clearCache');

        Route::post('init')->uses('SystemController@initData')->name('b_System_initData')->middleware('pwd.check');
    });

});

Route::namespace('Cms')->middleware(['CheckIsLogin','CheckAuth'])->group(function (){
    Route::prefix('article')->group(function (){

        /*文章分类*/
        Route::prefix('category')->group(function (){

            Route::get('list')->uses('ArticleCatController@index')->name('b_ArticleCat_index');

            Route::get('parent-category')->uses('ArticleCatController@getParentCat')->name('b_ArticleCat_getParentCat');

            Route::match(['post','get'],'add/{parent_id?}')->uses('ArticleCatController@addCat')->name('b_ArticleCat_addCat')
                ->where('parent_id','[0-9]+');

            Route::match(['post','get'],'edit/{id}')->uses('ArticleCatController@editCat')->name('b_ArticleCat_editCat')
                ->where('id','[0-9]+');

            Route::get('remove/{id}')->uses('ArticleCatController@delCat')->name('b_ArticleCat_delCat')
                ->where('id','[0-9]+');

        });

        Route::get('list')->uses('ArticleController@index')->name('b_Article_index');

        Route::match(['post','get'],'create')->uses('ArticleController@addArticle')->name('b_Article_addArticle');

        Route::match(['post','get'],'edit/{id}')->uses('ArticleController@editArticle')->name('b_Article_editArticle')
            ->where('id','[0-9]+');

        Route::get('switch/{id}')->uses('ArticleController@switchArticle')->name('b_Article_switchArticle')
            ->where('id','[0-9]+');

        Route::get('remove/{id}')->uses('ArticleController@delArticle')->name('b_Article_delArticle')
            ->where('id','[0-9]+');

        Route::get('/{id}')->uses('ArticleController@article')->name('b_Article_article')
            ->where('id','[0-9]+');

    });

    Route::prefix('notice')->group(function (){

        Route::get('/')->uses('NoticeController@index')->name('b_Notice_index');

        Route::match(['get','post'],'/issue')->uses('NoticeController@create')->name('b_Notice_create');

        Route::match(['get','post'],'edit/{id}')->uses('NoticeController@update')->name('b_Notice_update')
            ->where('id','[0-9]+');

        Route::get('switch/{id}')->uses('NoticeController@switchNotice')->name('b_Notice_switchNotice')
            ->where('id','[0-9]+');

        Route::get('remove/{id}')->uses('NoticeController@remove')->name('b_Notice_remove')
            ->where('id','[0-9]+');
    });

    Route::prefix('message')->group(function (){

        Route::get('/{type?}')->uses('MessageController@index')->name('b_Message_index')
            ->where('type','inbox|outbox');

        Route::get('detail/{id}')->uses('MessageController@detail')->name('b_Message_detail')
            ->where('id','[0-9]+');

        Route::get('read/{id}')->uses('MessageController@markedRead')->name('b_Message_markedRead')
            ->where('id','[0-9]+');

        Route::get('remove/{id}')->uses('MessageController@delete')->name('b_Message_delete')
            ->where('id','[0-9]+');

        Route::match(['post','get'],'send')->uses('MessageController@send')->name('b_Message_send');

        Route::match(['post','get'],'reply/{id}')->uses('MessageController@reply')->name('b_Message_reply')
            ->where('id','[0-9]+');

        Route::get('ajax-msg')->uses('MessageController@ajaxGetMessage')->name('b_Message_ajaxGetMessage');
    });

});

Route::namespace('User')->middleware(['CheckIsLogin','CheckAuth'])->group(function (){

    Route::prefix('user')->group(function (){

        Route::get('/')->uses('UserController@activatedUsers')->name('b_User_activatedUsers');

        Route::get('unactivated')->uses('UserController@unactivatedUsers')->name('b_User_unactivatedUsers');

        Route::get('frozen')->uses('UserController@frozenUsers')->name('b_User_frozenUsers');


        Route::get('activate/{id}')->uses('UserController@activatedUser')->name('b_User_activatedUser')
            ->where('id','[0-9]+');

        Route::get('empty_activate/{id}')->uses('UserController@EmptyActivatedUser')->name('b_User_empty_activatedUser')
            ->where('id','[0-9]+');


        Route::match(['post','get'],'create')->uses('UserController@createUser')->name('b_User_createUser');

        Route::match(['post','get'],'remove')->uses('UserController@deleteUser')->name('b_User_deleteUser');

        Route::get('freeze/{id}')->uses('UserController@freezeUser')->name('b_User_freezeUser')
            ->where('id','[0-9]+');

        Route::get('unfreezeUser/{id}')->uses('UserController@unfreezeUser')->name('b_User_unfreezeUser')
            ->where('id','[0-9]+');

        Route::get('info/{id}')->uses('UserController@infoUser')->name('b_User_infoUser')
            ->where('id','[0-9]+');

        Route::match(['post','get'],'edit/{id}/{action?}')->uses('UserController@editUser')->name('b_User_editUser')
            ->where(['id'=>'[0-9]+','action'=>'base|detail']);

        Route::match(['post','get'],'reset/{id}/{action?}')->uses('UserController@resetUserPwd')->name('b_User_resetUserPwd')
            ->where(['id'=>'[0-9]+','action'=>'login|safe']);

        Route::get('agree/{user_id}')->uses('UserController@agreeRealName')->name('b_User_agreeRealName')
            ->where(['user_id'=>'[0-9]+']);

        Route::get('ajax-info')->uses('UserController@getUserInfo')->name('b_User_getUserInfo');

        Route::get('export-user')->uses('UserController@exportUserData')->name('b_User_exportUserData');

        Route::get('access-user/{user_id}')->uses('UserController@visitFrontend')->name('b_User_visitFrontend')
            ->where(['user_id'=>'[0-9]+']);

        Route::get('point-user/{user_id}')->uses('UserController@updateStaticPoint')->name('b-users-point-num')
            ->where(['user_id'=>'[0-9]+']);


        Route::get('change-user-identity/{user_id}')->uses('UserController@ChangeUserIdentity')->name('b-users-change-user-identity')
            ->where(['user_id'=>'[0-9]+']);


        Route::get('relation')->uses('UserController@relationTree')->name('b_User_relationTree');
        Route::get('jiedian')->uses('UserController@jiedianTree')->name('b_User_jiedianTree');
        Route::get('orgchat')->uses('UserController@orgchat')->name('b_User_Orgchat');
        Route::get('nodechildren/{nid?}')->uses('UserController@nodechildren')->name('b_User_nodechildren');



        Route::post('ajax-children')->uses('UserController@asyncGetChildren')->name('b_User_asyncGetChildren');
        Route::post('ajax-jiedianchildren')->uses('UserController@asyncGetJiedianChildren')->name('b_User_asyncGetJiedianChildren');


        Route::get('important-user')->uses('UserController@importantUser')->name('b_User_important-user');


        Route::get('day-add-user-info/{id}')->uses('UserController@DayAddUserInfo')->name('b_User_day-add-user-info')
            ->where('id','[0-9]+');

    });

    Route::prefix('account')->group(function (){

        Route::match(['post','get'],'correction')->uses('AccountController@correctAccount')->name('b_Account_correctAccount');

        Route::get('flow')->uses('AccountController@accountFlow')->name('b_Account_accountFlow');

        Route::get('correct-flow')->uses('AccountController@correctFlow')->name('b_Account_correctFlow');

        Route::get('bonus-count')->uses('AccountController@bonusCount')->name('b_Account_bonusCount');

        Route::get('bonus-record')->uses('AccountController@bonusRecord')->name('b_Account_bonusRecord');

        Route::match(['post','get'],'month-award')->uses('AccountController@MonthAward')->name('b_Account_MonthAward');

        Route::match(['post','get'],'test-award')->uses('AccountController@TestAward')->name('b_Account_test-award');

    });

    Route::prefix('wd')->group(function (){

        Route::get('record')->uses('WdController@wdRecord')->name('b_Wd_wdRecord');

        Route::get('apply')->uses('WdController@wdApply')->name('b_Wd_wdApply');

        Route::get('detail/{wd_id}')->uses('WdController@wdDetail')->name('b_Wd_wdDetail')
            ->where('wd_id','[0-9]+');

        Route::match(['post','get'],'remove')->uses('WdController@wdDelete')->name('b_Wd_wdDelete');

        Route::match(['post','get'],'agree/{wd_id}')->uses('WdController@wdAgree')->name('b_Wd_wdAgree')->where('wd_id','[0-9]+');

        Route::post('refuse/{wd_id}')->uses('WdController@wdRefuse')->name('b_Wd_wdRefuse')->where('wd_id','[0-9]+');

    });

    Route::prefix('rg')->group(function (){
        Route::get('list')->uses('RechargeController@rechargeList')->name('b_Recharge_rechargeList');

        Route::get('apply')->uses('RechargeController@rgApply')->name('b_Recharge_rgApply');

        Route::get('detail/{id}')->uses('RechargeController@detail')->name('b_Recharge_detail')->where('id','[0-9]+');

        Route::match(['post','get'],'remove')->uses('RechargeController@delete')->name('b_Recharge_delete');

        Route::get('agree/{id}')->uses('RechargeController@rgAgree')->name('b_Recharge_rgAgree')->where('id','[0-9]+');

        Route::post('refuse/{id}')->uses('RechargeController@rgRefuse')->name('b_Recharge_rgRefuse')->where('id','[0-9]+');
    });

    Route::prefix('tf')->group(function (){

        Route::get('record')->uses('TfController@tfRecord')->name('b_Tf_tfRecord');

    });

    Route::prefix('up')->group(function (){

        Route::get('record')->uses('UpgradeController@upRecord')->name('b_Up_upRecord');

        Route::get('apply')->uses('UpgradeController@upApply')->name('b_Up_upApply');

        Route::get('detail/{id}')->uses('UpgradeController@detail')->name('b_Up_detail')->where('id','[0-9]+');
    });

});

Route::namespace('Stats')->prefix('stats')->middleware(['CheckIsLogin','CheckAuth'])->group(function (){

    Route::get('plat')->uses('PlatStatsController@countData')->name('b_PlatStats_countData');

    Route::get('chart-rg')->uses('PlatStatsController@chartRgData')->name('b_PlatStats_chartRgData');

    Route::get('ct-ratio')->uses('PlatStatsController@ctRatio')->name('b_PlatStats_ctRatio');

    Route::get('ct-user')->uses('PlatStatsController@exportCtUser')->name('b_PlatStats_exportCtUser');

    Route::get('count-coupon')->uses('PlatStatsController@countCoupon')->name('b_PlatStats_countCoupon');


    Route::get('sales')->uses('ShopStatsController@salesStats')->name('b_ShopStats_salesStats');

    Route::get('count-sales')->uses('ShopStatsController@salesCount')->name('b_ShopStats_salesCount');


    Route::get('bonus_pools')->uses('PlatStatsController@BonusPools')->name('b_PlatStats_bonus_pools');

    Route::get('bonus_pools_list/{type}')->uses('PlatStatsController@BonusPoolsList')->name('b_PlatStats_bonus_pools_list')->where('type','[0-9]+');

});

Route::namespace('Lottery')->middleware(['CheckIsLogin','CheckAuth'])->group(function (){

    Route::prefix('lottery')->group(function (){
        Route::prefix('prize')->group(function (){

            Route::get('index')->uses('PrizeController@index')->name('b_lottery_prize_index');
            Route::match(['post','get'],'create')->uses('PrizeController@create')->name('b_lottery_prize_create');
            Route::match(['post','get'],'update/{id}')->uses('PrizeController@update')->name('b_lottery_prize_update')
                ->where('id','[0-9]+');
            Route::get('delete/{id}')->uses('PrizeController@delete')->name('b_lottery_prize_delete')
                ->where('id','[0-9]+');

        });
        Route::prefix('win')->group(function (){

            Route::get('index')->uses('WinController@index')->name('b_lottery_win_index');
            Route::get('delete/{id}')->uses('WinController@delete')->name('b_lottery_win_delete')
                ->where('id','[0-9]+');
            Route::match(['post','get'],'hx/{id}')->uses('WinController@hx')->name('b_lottery_win_hx')->where('id','[0-9]+');
            Route::match(['post','get'],'zf/{id}')->uses('WinController@zf')->name('b_lottery_win_zf')->where('id','[0-9]+');
        });

    });

});